/*
 * @lc app=leetcode.cn id=653 lang=javascript
 *
 * [653] 两数之和 IV - 输入 BST
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} k
 * @return {boolean}
 */
var findTarget = function(root, k) {
    let map=new Map()
    let dfs=function(node){
        if(!node)return false
        
        if(map.has(k-node.val)){
            return true
        }else{
            map.set(node.val,false)
        }
        return dfs(node.left)||dfs(node.right)
    }
    return dfs(root)
};
// @lc code=end

